package com.lynn.salary.web.action;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.lynn.salary.entity.SystemFile;
import com.lynn.salary.service.IUserService;
import com.lynn.salary.service.ISysArgumentService;
import com.lynn.salary.util.ObjectFactory;

public class ExportAction extends BaseAction {

	private String month;
	IUserService userService = (IUserService) ObjectFactory
			.getBean("userService");
	ISysArgumentService sysArgumentService = (ISysArgumentService) ObjectFactory
			.getBean("sysArgumentService");
	private ArrayList<List<String>> salaryReport;
	private String flag;
	private File exportFile;

	/*
	 * public String salaryReportExport() throws Exception { month = "201206";
	 * salaryReport = statisticsService.salaryReport(month);
	 * 
	 * exportFile = ExcelCreator.instance.salaryReport(salaryReport, month);
	 * 
	 * return "export"; }
	 */

	/*
	 * public String exportMonthReport() throws Exception {
	 * 
	 * Object[] args = (Object[]) RemoteService.cache.get(flag); String type =
	 * (String) args[0]; String time = (String) args[1]; String st = (String)
	 * args[2]; String et = (String) args[3]; String[] eds = (String[]) args[4];
	 * RemoteService.cache.remove(flag);
	 * 
	 * List<ArrayList<String>>report = employeeService.monthReport(type, time,
	 * st, et, eds); String timeString = ""; if(time.equals("1")) { //本月 Date d
	 * = new Date(); SimpleDateFormat f = new SimpleDateFormat("yyyy年MM月");
	 * timeString = f.format(d); }else if(time.equals("2")){ //上月 Date d = new
	 * Date(); Calendar c = Calendar.getInstance(); c.setTime(d);
	 * c.set(Calendar.MONTH, c.get(Calendar.MONTH)-1); SimpleDateFormat f = new
	 * SimpleDateFormat("yyyy年MM月"); timeString = f.format(c.getTime()); } else
	 * if(time.equals("3")) { //自定义 timeString = st + " -- " + et; } exportFile
	 * = ExcelCreator.instance.kaoqinReport(report,timeString);
	 * 
	 * return "export"; }
	 */

	public String getSystemFile() throws Exception {
		SystemFile f = sysArgumentService.findSfById(flag);
		exportFile = new File(f.getSavePath());
		System.out.println("asdfadfafd" + exportFile.exists());
		return "export";
	}

	public String getMonth() {
		return month;
	}

	public void setMonth(String month) {
		this.month = month;
	}

	public ArrayList<List<String>> getSalaryReport() {
		return salaryReport;
	}

	public void setSalaryReport(ArrayList<List<String>> salaryReport) {
		this.salaryReport = salaryReport;
	}

	public File getExportFile() {
		return exportFile;
	}

	public IUserService getEmployeeService() {
		return userService;
	}

	public void setEmployeeService(IUserService employeeService) {
		this.userService = employeeService;
	}

	public String getFlag() {
		return flag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

	public void setExportFile(File exportFile) {
		this.exportFile = exportFile;
	}

}
